cmake_minimum_required(VERSION 3.0.0)
project(plugin-database VERSION 1.0.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt5 COMPONENTS Core Widgets Sql REQUIRED)
find_package(DtkWidget REQUIRED)
find_package(duc-base REQUIRED)
find_package(duc-common REQUIRED)
find_package(duc-framework REQUIRED)
find_package(duc-services REQUIRED)

add_library(${PROJECT_NAME} SHARED
    src/databaseplugin.cpp
    src/connectionwidget.cpp
    src/connectiondialog.cpp
)

target_include_directories(${PROJECT_NAME} PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/src
)

target_link_libraries(${PROJECT_NAME}
    ${duc-framework_LIBRARIES}
    ${duc-base_LIBRARIES}
    ${duc-common_LIBRARIES}
    ${duc-services_LIBRARIES}
    Qt5::Core
    Qt5::Widgets
    Qt5::Sql
    ${DtkWidget_LIBRARIES}
)

if(NOT PLUGIN_INSTALL_PATH)
    set(PLUGIN_INSTALL_PATH "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/deepin-unioncode/plugins")
endif()

install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
install(FILES database.json DESTINATION ${PLUGIN_INSTALL_PATH})